using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Water : MonoBehaviour
{
    public float buoyancyFactor;
    public float waveHeightFactor;
    public float waveSpeedFactor;
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.GetComponent<PlayerController>())
            return;

        var curGlove = collision.GetComponent<Rigidbody2D>();
        var wave = Mathf.Sin(collision.transform.position.x + Time.time * waveSpeedFactor) * waveHeightFactor;
        curGlove.AddForce(Vector2.up * buoyancyFactor * (5.0f - collision.transform.position.y + wave));
    }
}
